#include <iostream>
using namespace std;
#include <fstream>
#include <istream>

int main()
{
    fstream f("f.txt", ios::in | ios::out | ios::app);
    if (!f)
        cout << "open error io" << endl;

    f << "aaaaa" << endl;
    f << "bbbbb" << endl;

    fstream o("o.txt", ios::in | ios::out | ios::app);
    f.seekg(0, ios::beg); //从beg第0个字节处开始

    char ch;
    while (f.get(ch), !f.eof())
    {
        o.put(ch);  //读取f，放到o文件中
    }

    return 0;
}